//获取应用实例
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    navData: [
      {
        name: "首页",  //文本
        current: 0,    //是否是当前页，0不是  1是
        style: 0,     //样式
        icourl: '/images/icon/ic_shouye.png',  //不同图标
        fn: 'gotoIndex'   //对应处理函数
      }, {
        name: "分类",
        current: 0,
        style: 0,
        icourl: '/images/icon/ic_fenlei.png',
        fn: 'gotoOldGoods'
      }, {
        name: "AI量体",
        current: 0,
        style: 1,
        ico: '',
        fn: 'gotoPublish'
      }, {
        name: "专题",
        current: 1,
        style: 0,
        icourl: '/images/icon/ic_zhuanti_2.png',
        fn: 'gotoRecruit'
      }, {
        name: "我的",
        current: 0,
        style: 0,
        icourl: '/images/icon/ic_wode.png',
        fn: 'gotoMine'
      },
    ],
    winWidth: 0,  
    winHeight: 0,  
    scrollTop : 0,
    // tab切换  
    currentTab: 0, 
    productionTab: 0,
    status: 0,
  },
  changeStatus(e) {
    let that = this;
    let status = e.currentTarget.id;
    that.setData({
      status: status
    })
  },
  gotoIndex:function(){
    wx.redirectTo({
      url: '/pages/index/index',
    });
  },
  gotoOldGoods:function(){
    wx.redirectTo({
      url: '/pages/oldgoods/oldgoods',
    });
  },
  gotoPublish:function(){
    wx.redirectTo({
      url: '/pages/publish/publish',
    });
  },
  gotoMine:function(){
    wx.redirectTo({
      url: '/pages/mine/mine',
    });
  },
  // 联系他
  contact: function () {
    wx.showModal({
      title: '温馨提示',
      content: '您将要拨打电话：13298176895',
      success: function (res) {
        if (res.confirm) {
          wx.makePhoneCall({
            phoneNumber: '13298176895',
            success: function () {
              console.log("成功拨打电话")
            }
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  // 查看大图
  preView: function (e){    
    wx.previewImage({
      current: e.target.dataset.img,
      urls: [e.target.dataset.img],
      success:function(res){    
           
      },
      fail:function(res){        
      },
    });      
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
   var that = this;
    /** 
     * 获取系统信息 
     */  
    wx.getSystemInfo( {    
      success: function( res ) {  
        that.setData( {  
          winWidth: res.windowWidth,  
          winHeight: res.windowHeight  
        });  
      }   
    }); 
    that.setData({
      msgList: [
        { url: "url", title: "跳蚤市场已经更新至v1.0.1，修复大量的兼容问题！" },
        { url: "url", title: "感谢您对我们的支持！您的关注是我们最大的动力！" },]
    });  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  },
})
